<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
		//根据课件动物类的例子，尝试定义更多的动物重写sound方法，比如：狗、猫等，至少3种。
			function Animal(type){//父类
				this.type=type;
			}
			//  原型对象      
			Animal.prototype.sound=function(){
				console.log(this.type+"发出叫声");
			}
			function F(){};
			//寄生
			F.prototype=Animal.prototype;
			//狗 子类
			function Dog(type){
				Animal.call(this,"狗");
			}
			Dog.prototype=new F();//原型链继承
			Dog.prototype.constructor=Dog;// 修复构造函数
			
			Dog.prototype.sound=function(){//父类重写
				console.log(this.type+"汪汪叫");
			}
			let dog=new Dog();
			dog.sound();
			//猫
			function Cat (type){
				Animal.call(this,"猫");
			}
			Cat.prototype=new F();
			Cat.prototype.constructor=Cat;
			Cat.prototype.sound=function(){
				console.log(this.type+"喵喵叫");
			}
			let dog=new Dog();
			cat.sound();
			//🐂
			function Cow(){
				Animal.call(this,"猫");
			}
			Cow.prototype=new F();
			Cow.prototype.constructor=Cow;
			Cow.prototype.sound(){
				console.log(this.type+"哞哞叫");
			}
			let cow=new Cow();
			cow.sound();
		</script>
	</body>
</html>
